﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace eLearning.Business
{
    public class ApplicationContentRepository
    {
        // Create an instance of entities framework
        eLearningEntities entities = new eLearningEntities();
        public List<ApplicationContent> GetAll()
        {
            return (from c in entities.ApplicationContents select c).ToList();
        }
        public ApplicationContent GetSingle(string id)
        {
            return (from c in entities.ApplicationContents where c.PageName == id select c).FirstOrDefault();
        }
        public void Create(ApplicationContent _object)
        {
            entities.AddToApplicationContents(_object);
            entities.SaveChanges();
        }
        public void Update(ApplicationContent _object)
        {
            entities.SaveChanges();
        }
        public void Delete(string id)
        {
            var _object = (from _list in entities.ApplicationContents where _list.PageName == id select _list).First();
            entities.DeleteObject(_object);
            entities.SaveChanges();
        }
    }
}